package com.playfair.dictionary;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.nio.charset.Charset;
import java.text.DecimalFormat;

public class TrigramsRemaker {
	public static void main(String[] args) {
		String line;
		FileInputStream fis = null;
		FileWriter fw = null;
		Double total=new Double(4445);
		DecimalFormat df = new DecimalFormat("#.##########");
		try {
			fis = new FileInputStream("trigrams");
			fw = new FileWriter("trg");
			BufferedReader br = new BufferedReader(new InputStreamReader(fis,
					Charset.forName("UTF-8")));
			BufferedWriter bw = new BufferedWriter(fw);

			while ((line = br.readLine()) != null) {

				// if (!line.contains("#")) {
				// bw.write(line.trim() + "\n");
				// bw.flush();
				// System.out.println(6);
				// }
				
				// line = br.readLine();
				// total += Integer.valueOf(line);
				
				String nmb = br.readLine();
				Double newNmb = Double.valueOf(nmb)/total;
				 bw.write(line.trim() + "\n" + df.format(newNmb) + "\n");
				 bw.flush();

			}
			bw.close();
			br.close();
		} catch (FileNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

	}
}
